package com.flame.shapeville.component.task1.shape2D;

import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;

/**
 * Represents a regular pentagon used in Task 1.
 * <p>
 * This class draws a five-sided polygon with equal angles and side lengths.
 *
 * @author Flame Dev Team
 * @version 1.0
 * @since 2025-05-12
 */
public class JfPentagon extends JfShape2D {

    /**
     * Constructs a new pentagon with the specified size.
     *
     * @param size the bounding box size for the pentagon
     */
    public JfPentagon(double size) {
        this.size = size;
        // s = r + r * cos(360 / 5 / 2)
        double r = size / (1 + Math.cos(Math.toRadians(36.0)));
        shape = new Polygon(
                size / 2, 0,
                size / 2 - r * Math.sin(Math.toRadians(72.0)), r - r * Math.cos(Math.toRadians(72.0)),
                size / 2 - r * Math.sin(Math.toRadians(36.0)), size,
                size / 2 + r * Math.sin(Math.toRadians(36.0)), size,
                size / 2 + r * Math.sin(Math.toRadians(72.0)), r - r * Math.cos(Math.toRadians(72.0))
        );
        initBaseParams(Color.CYAN);
    }
}
